use QcScript::core::JsComponentData;

use super::message::ComponentType;

#[derive(Debug, Clone)]
pub enum ComponentData {
    Js(JsComponentData),
    Native(ComponentType),
}

impl ComponentData {
    pub fn get_name(&self) -> &str {
        match self {
            ComponentData::Js(comp) => &comp.name,
            ComponentData::Native(comp) => (*comp).into(),
        }
    }
}

impl Into<ComponentData> for JsComponentData {
    fn into(self) -> ComponentData {
        ComponentData::Js(self)
    }
}

impl Into<ComponentData> for ComponentType {
    fn into(self) -> ComponentData {
        ComponentData::Native(self)
    }
}
